package com.sino.second.util;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;


import com.sino.bean.Basicinfo;
import com.sino.bean.TblZhuanjiarukuxinxibiao;
import com.sino.model.BasicInfoModel;
import com.sino.model.ExpertModel;
import com.sino.second.bean.SysXmpsdj;
import com.sino.second.bean.SysXmpszb;
import com.sino.second.bean.TblXmfs1;
import com.sino.second.bean.TblXmfs2;
import com.sino.second.bean.TblXmfs3;
import com.sino.second.bean.TblXmjg1;
import com.sino.second.bean.TblXmjg2;
import com.sino.second.bean.TblXmjg3;
import com.sino.second.bean.TblXmpfbz;
import com.sino.second.model.ExpertsReviewModel;
import com.sino.second.model.ExpertsReviewModel1;
import com.sino.second.model.ExpertsReviewModel2;
import com.sino.second.model.ExpertsReviewModel3;
import com.sino.second.model.XmReviewResults1;
import com.sino.second.model.XmReviewResults2;
import com.sino.second.model.XmReviewResults3;
import com.sino.second.model.XmpfbzModel;
import com.sino.second.model.XmpsdjModel;
import com.sino.second.model.XmpszbModel;

public class BeanAndModelConverter {
	/**
	 * 项目评审等级转化方法 将SysXmpsdj转化为XmpsdjModel
	 * 
	 * @param sysXmpsdj
	 * @return
	 */
	public static XmpsdjModel getXmpsdjModelByXmpsdjBean(SysXmpsdj sysXmpsdj) {
		XmpsdjModel xmpsdjModel = new XmpsdjModel();
		if (null != sysXmpsdj) {
			xmpsdjModel.setId(sysXmpsdj.getId());
			xmpsdjModel.setName(sysXmpsdj.getName());
		}
		return xmpsdjModel;
	}
    
	/**
	 * 项目评审等级转化方法 将XmpsdjModel转化为SysXmpsdj
	 * 
	 * @param sysXmpsdj
	 * @return
	 */
	public static SysXmpsdj getXmpsdjByXmpsdjModel(XmpsdjModel xmpsdjModel) {
		SysXmpsdj sysXmpsdj = new SysXmpsdj();
		if (null != xmpsdjModel) {
			sysXmpsdj.setId(xmpsdjModel.getId());
			sysXmpsdj.setName(xmpsdjModel.getName());
		}
		return sysXmpsdj;
	}
	/**
	 * 项目基础信息转化方法 将Basicinfo转化为BasicInfoModel
	 * 
	 * @param basicinfo
	 * @return
	 */
	public static BasicInfoModel getBasicInfoModel(Basicinfo basicinfo) {
		BasicInfoModel basicInfoModel = new BasicInfoModel();
		if (null != basicinfo) {
			basicInfoModel.setZlid(basicinfo.getZlid());
			basicInfoModel.setName(basicinfo.getName());
			basicInfoModel.setZlqr(basicinfo.getZlqr());
			basicInfoModel.setZlid2(basicinfo.getZlid2());
			basicInfoModel.setLxdh(basicinfo.getLxdh());
			basicInfoModel.setYddh(basicinfo.getYddh());
			if(null!=basicinfo.getXk())
			{
				basicInfoModel.setXk(basicinfo.getXk().getId());
				basicInfoModel.setXkmc(basicinfo.getXk().getName());
			}
			if(null!=basicinfo.getQxkw())
			{
				basicInfoModel.setQxkwmc(basicinfo.getQxkw().getName());
			}
		    basicInfoModel.setFmr(basicinfo.getFmr());
		}
		return basicInfoModel;
	}
  /**
   * 项目基础信息转化方法 将BasicInfoModel转化为Basicinfo
   * @param basicInfoModel
   * @return
   */
	public static Basicinfo getBasicinfoByBasicInfoModel(BasicInfoModel basicInfoModel) 
	{
		Basicinfo basicinfo=new Basicinfo();
		if(null!=basicInfoModel)
		{
			basicinfo.setZlid(basicInfoModel.getZlid());
		}
		return basicinfo;
	}
	/**
	 * 初审 Model转化 PO
	 * @param tx1
	 * @return
	 */
	public static ExpertsReviewModel getExpertsReviewModel1(TblXmfs1 tx1){
		ExpertsReviewModel1 erm1=new ExpertsReviewModel1();
		erm1.setFzqz(tx1.getFzqz());
		
		erm1.setYear(tx1.getYear());
		erm1.setPsrq(tx1.getPsrq());
		erm1.setId(tx1.getId());
		erm1.setState(tx1.getState());
		erm1.setXmfs(tx1.getXmfs());
	  	erm1.setBasicInfoModel(BeanAndModelConverter.getBasicInfoModel(tx1.getBasicinfo()));
		erm1.setExpertModel(BeanAndModelConverter.getExpertModel(tx1.getTblZhuanjiarukuxinxibiao()));
		erm1.setXmpsbzModel(BeanAndModelConverter.getXmpfbzModel(tx1.getTblXmpfbz()));
		erm1.setXmpszbModel(BeanAndModelConverter.getXmpszbModel(tx1.getSysXmpszb()));
		return erm1;
	}
	/**
	 * 复审 Model转化 PO
	 * @param tx1
	 * @return
	 */
	public static ExpertsReviewModel getExpertsReviewModel2(TblXmfs2 tx2){
		ExpertsReviewModel2 erm2=new ExpertsReviewModel2();
		erm2.setFzqz(tx2.getFzqz());
		erm2.setYear(tx2.getYear());
		erm2.setPsrq(tx2.getPsrq());
		erm2.setId(tx2.getId());
		erm2.setState(tx2.getState());
		erm2.setXmfs(tx2.getXmfs());
		erm2.setBasicInfoModel(BeanAndModelConverter.getBasicInfoModel(tx2.getBasicinfo()));
		erm2.setExpertModel(BeanAndModelConverter.getExpertModel(tx2.getTblZhuanjiarukuxinxibiao()));
		erm2.setXmpsbzModel(BeanAndModelConverter.getXmpfbzModel(tx2.getTblXmpfbz()));
		erm2.setXmpszbModel(BeanAndModelConverter.getXmpszbModel(tx2.getSysXmpszb()));
		erm2.setJydj(BeanAndModelConverter.getXmpsdjModelByXmpsdjBean(tx2.getSysXmpsdj()));
		return erm2;
	}

	
	public static XmpszbModel getXmpszbModel(SysXmpszb sx){
		XmpszbModel xsm=new XmpszbModel();
		xsm.setId(sx.getId());
		xsm.setCheckFlag(false);
		xsm.setNote(sx.getNote());
		xsm.setName(sx.getName());
		xsm.setWeight(sx.getWeight());
	    List<XmpfbzModel> txfList=new ArrayList<XmpfbzModel>();
		Set<TblXmpfbz> txfSet=sx.getTblXmpfbzs();
		for(TblXmpfbz txf:txfSet){
			txfList.add(BeanAndModelConverter.getXmpfbzModel(txf));
		}
		xsm.setTxfList(txfList);
		return xsm;
		
	}
	public static XmpfbzModel getXmpfbzModel(TblXmpfbz txf){
		XmpfbzModel xfm=new XmpfbzModel();
	    xfm.setId(txf.getId());
	    xfm.setName(txf.getName());
	    xfm.setNote(txf.getNote());
	    xfm.setScore(txf.getScore());
	    return xfm;
		
	}
	/**
	 * 项目复审结果转化方法 将TblXmjg2转化为XmReviewResults2
	 * 
	 * @param tblXmjg2
	 * @return
	 */
	public static XmReviewResults2 getXmReviewResults2ByTblXmjg2(
			TblXmjg2 tblXmjg2) {
		XmReviewResults2 xrr2 = new XmReviewResults2();
		if (null != tblXmjg2) {
			xrr2.setId(tblXmjg2.getId());
			xrr2.setJydj(getXmpsdjModelByXmpsdjBean(tblXmjg2.getSysXmpsdj()));
			xrr2.setBasicInfoModel(getBasicInfoModel(tblXmjg2.getBasicinfo()));
			xrr2.setPsrq(tblXmjg2.getPsrq());
			xrr2.setUsername(tblXmjg2.getUsername());
			xrr2.setYear(tblXmjg2.getYear());
			xrr2.setXmzf(tblXmjg2.getXmzf());
			xrr2.setXmpjf(tblXmjg2.getXmpjf());
			xrr2.setXmpjpxfx(tblXmjg2.getXmpjpxfs());
		}
		return xrr2;
	}

	
	public static TblXmjg2 getTblXmjg2ByXmReviewResults2(XmReviewResults2 xmReviewResults2)
	{
		TblXmjg2 xmjg2=new TblXmjg2();
		xmjg2.setBasicinfo(getBasicinfoByBasicInfoModel(xmReviewResults2.getBasicInfoModel()));
		xmjg2.setXmzf(xmReviewResults2.getXmzf());
		xmjg2.setXmpjf(xmReviewResults2.getXmpjf());
		xmjg2.setUsername(xmReviewResults2.getUsername());
		xmjg2.setPsrq(xmReviewResults2.getPsrq());
		xmjg2.setYear(xmReviewResults2.getYear());
		xmjg2.setXmpjpxfs(xmReviewResults2.getXmpjpxfx());
		return xmjg2;
		
	}
	
	/**
	 * 专家库信息转化方法 将TblZhuanjiarukuxinxibiao转化为ExpertModel
	 * 
	 * @param tzjb
	 * @return
	 */
	public static ExpertModel getExpertModel(TblZhuanjiarukuxinxibiao tzjb) {
		ExpertModel em = new ExpertModel();
		em.setFBh(tzjb.getFBh());
		em.setXm(tzjb.getXm());
		em.setXb(tzjb.getXb());
		em.setXwhchHd(tzjb.getXwhchHd());
		em.setBYShJ(tzjb.getByshJ());
		em.setByyx(tzjb.getByyx());
		em.setChShRq(tzjb.getChShRq());
		em.setDwchZh(tzjb.getDwchZh());
		em.setDzyx(tzjb.getDzyx());
		em.setDwdh(tzjb.getDwdh());
		em.setDzyx(tzjb.getDzyx());
		em.setDwchZh(tzjb.getDwchZh());
		em.setFYhm(tzjb.getFYhm());// users
		em.setGzdw(tzjb.getGzdw());// office
		em.setJj(tzjb.getJj());
		em.setJtdzh(tzjb.getJtdzh());
		em.setJtdhhm(tzjb.getJtdhhm());
		em.setJtdzhyb(tzjb.getJtdzhyb());
		em.setMm(tzjb.getMm());
		em.setMqcshZhY(tzjb.getMqcshZhY());
		em.setShFysh(tzjb.getShFysh());
		em.setShFbd(tzjb.getShFbd());
		em.setShFshCh(tzjb.getShFshCh());
		em.setRkshj(tzjb.getRkshj());
		em.setShXxk(tzjb.getShXxk());
		em.setShHjzh(tzjb.getShHjzh());
		em.setShJ(tzjb.getShJ());
		if(null!=tzjb.getSysDanweixingzhima()&&tzjb.getSysDanweixingzhima().getShM().length()>0)
		{
			em.setSysDanweixingzhima(tzjb.getSysDanweixingzhima().getShM());
		}
		if(null!=tzjb.getSysShenhezhuangtaima()&&tzjb.getSysShenhezhuangtaima().getShM().length()>0)
		{
			em.setSysShenhezhuangtaima(tzjb.getSysShenhezhuangtaima().getShM());
		}
		if(null!=tzjb.getSysXueweima()&&tzjb.getSysXueweima().getShM().length()>0)
		{
			em.setSysXueweima(tzjb.getSysXueweima().getShM());
		}
		if(null!=tzjb.getSysZhichengma()&&tzjb.getSysZhichengma().getShM().length()>0)
		{
			em.setSysZhichengma(tzjb.getSysZhichengma().getShM());
		}
		if(null!=tzjb.getSysZhiwuma()&&tzjb.getSysZhiwuma().getShM().length()>0)
		{
			em.setSysZhiwuma(tzjb.getSysZhiwuma().getShM());
		}
		if(null!=tzjb.getSysZhuanyema()&&tzjb.getSysZhuanyema().getShM().length()>0)
		{
			em.setSysZhuanyema(tzjb.getSysZhuanyema().getShM());
		}
		if(null!=tzjb.getSysZhuanyema()&&tzjb.getSysZhuanyema().getBm().length()>0)
		{
			em.setSysZhuanyemamc(tzjb.getSysZhuanyema().getBm());
		}
		if(null!=tzjb.getFMz()&&tzjb.getFMz().getShM().length()>0)
		{
			em.setFMz(tzjb.getFMz().getShM());
		}
		return em;
	}
    
	/**
	 * 专家库信息转化方法 将ExpertModel转化为TblZhuanjiarukuxinxibiao
	 * 
	 * @param tzjb
	 * @return
	 */
	public static TblZhuanjiarukuxinxibiao getTblZhuanjiarukuxinxibiaoByExpertModel(ExpertModel expertModel) {
		TblZhuanjiarukuxinxibiao tzj = new TblZhuanjiarukuxinxibiao();
		tzj.setFBh(expertModel.getFBh());
		return tzj;
	}
	/**
	 * 大评委分数表转化方法 将ExpertsReviewModel3转化为TblXmfs3
	 * @param expertsReviewModel3
	 * @return
	 */
	public static TblXmfs3 getTblXmfs3ByExpertsReviewModel3(
			ExpertsReviewModel3 expertsReviewModel3) {
		TblXmfs3 xmfs3 = new TblXmfs3();
		xmfs3.setBasicinfo(getBasicinfoByBasicInfoModel(expertsReviewModel3.getBasicInfoModel()));
//		xmfs3.setJydj(getXmpsdjByXmpsdjModel(expertsReviewModel3.getJydj()));
		xmfs3.setPsrq(expertsReviewModel3.getPsrq());
//		xmfs3.setPxdj(getXmpsdjByXmpsdjModel(expertsReviewModel3.getPxjj()));
		xmfs3.setYear(expertsReviewModel3.getYear());
		xmfs3.setTblZhuanjiarukuxinxibiao(getTblZhuanjiarukuxinxibiaoByExpertModel(expertsReviewModel3.getExpertModel()));
		return xmfs3;
	}
	/**
	 * 大评委分数表转化方法 将TblXmfs3转化为ExpertsReviewModel3 
	 * @param expertsReviewModel3
	 * @return
	 */
	public static ExpertsReviewModel3 getExpertsReviewModel3ByTblXmfs3(TblXmfs3 tblXmfs3)
	{
		ExpertsReviewModel3 expertsReviewModel3=new ExpertsReviewModel3();
		expertsReviewModel3.setBasicInfoModel(getBasicInfoModel(tblXmfs3.getBasicinfo()));
		expertsReviewModel3.setJydj(getXmpsdjModelByXmpsdjBean(tblXmfs3.getJydj()));
		expertsReviewModel3.setPxjj(getXmpsdjModelByXmpsdjBean(tblXmfs3.getPxdj()));
		expertsReviewModel3.setPsrq(tblXmfs3.getPsrq());
		expertsReviewModel3.setYear(tblXmfs3.getYear());
		expertsReviewModel3.setExpertModel(getExpertModel(tblXmfs3.getTblZhuanjiarukuxinxibiao()));
		return expertsReviewModel3;
	}
	/**
	 * 大评委结果表转化方法 将xmReviewResults3转化为TblXmjg3
	 * @param xmReviewResults3
	 * @return
	 */
	public static TblXmjg3 getTblXmjg3ByXmReviewResults3(XmReviewResults3 xmReviewResults3)
	{
		TblXmjg3 xmjg3=new TblXmjg3();
		xmjg3.setBasicinfo(getBasicinfoByBasicInfoModel(xmReviewResults3.getBasicInfoModel()));
		xmjg3.setPsrq(xmReviewResults3.getPsrq());
		xmjg3.setPs(xmReviewResults3.getPs());
		xmjg3.setYear(xmReviewResults3.getYear());
		xmjg3.setUsername(xmReviewResults3.getUsername());
		return xmjg3;
	}
	/**
	 * 大评委结果表转化方法 将TblXmjg3转化为XmReviewResults3
	 * @param xmjg3
	 * @return
	 */
	public static XmReviewResults3 getXmReviewResults3ByTblXmjg3(TblXmjg3 xmjg3)
	{
		XmReviewResults3 xmReviewResults3=new XmReviewResults3();
		xmReviewResults3.setBasicInfoModel(getBasicInfoModel(xmjg3.getBasicinfo()));
		xmReviewResults3.setPsrq(xmjg3.getPsrq());
		xmReviewResults3.setPs(xmjg3.getPs());
		xmReviewResults3.setYear(xmjg3.getYear());
		xmReviewResults3.setUsername(xmjg3.getUsername());
		xmReviewResults3.setJydj(getXmpsdjModelByXmpsdjBean(xmjg3.getJydj()));
		xmReviewResults3.setPxjj(getXmpsdjModelByXmpsdjBean(xmjg3.getPxjj()));
		return xmReviewResults3;
	}
	/**
	 * 初审结果表转化方法 将xmReviewResults1转化为TblXmjg1
	 * 
	 * @param xmReviewResults3
	 * @return
	 */
	public static TblXmjg1 getTblXmjg1ByXmReviewResults1(
			XmReviewResults1 xmReviewResults1) {
		TblXmjg1 xmjg1 = new TblXmjg1();
		xmjg1.setBasicinfo(getBasicinfoByBasicInfoModel(xmReviewResults1
				.getBasicInfoModel()));
		xmjg1.setPsrq(xmReviewResults1.getPsrq());
		xmjg1.setIspass(xmReviewResults1.getIspass());
		xmjg1.setYear(xmReviewResults1.getYear());
		xmjg1.setUsername(xmReviewResults1.getUsername());
		xmjg1.setXmpjf(xmReviewResults1.getXmpjf());
		xmjg1.setXmpjpxfx(xmReviewResults1.getXmpjpxfx());
		xmjg1.setXmzf(xmReviewResults1.getXmzf());
		xmjg1.setYpzjs(xmReviewResults1.getYpzjs());
		return xmjg1;
	}

	public static XmReviewResults1 getXmReviewResults1ByTblXmjg1(TblXmjg1 xmjg1) {
		XmReviewResults1 xmReviewResults1 = new XmReviewResults1();
		xmReviewResults1.setBasicInfoModel(getBasicInfoModel(xmjg1
				.getBasicinfo()));
		xmReviewResults1.setPsrq(xmjg1.getPsrq());
		xmReviewResults1.setYear(xmjg1.getYear());
		xmReviewResults1.setUsername(xmjg1.getUsername());
		xmReviewResults1.setIspass(xmjg1.getIspass());
		xmReviewResults1.setPsrq(xmjg1.getPsrq());
		xmReviewResults1.setXmpjf(xmjg1.getXmpjf());
		xmReviewResults1.setXmpjpxfx(xmjg1.getXmpjpxfx());
		xmReviewResults1.setXmzf(xmjg1.getXmzf());
		xmReviewResults1.setYpzjs(xmjg1.getYpzjs());
			
		return xmReviewResults1;
	}
}